package com.feng.common.validation.validator;

import com.feng.common.validation.constraints.RoleLevel;
import com.feng.security.config.SecurityConst;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author Feng
 * @since 2022/4/19 21:01
 */
public class RoleLevelValidator implements ConstraintValidator<RoleLevel, Integer> {
    @Override
    public boolean isValid(Integer level, ConstraintValidatorContext context) {
        return level == null || level <= SecurityConst.ROLE_LEVEL_MAX_VALUE && level >= SecurityConst.ROLE_LEVEL_MIN_VALUE;
    }
}
